<template tag="以下文档内容为hycli自动生成">
  <div style="height: 100%">
    <div style="margin:0.8rem;"><h5 style="display:inline">字典表</h5><span style="margin-left: 0.5rem; color:#999"> </span>
    </div>
    <hr style="margin-top:0;color:#999"/>
<div class="query">
    
    <el-form :model="form_aabbb" inline >
        <!-- 日期控件个数： 0 -->
        <!--类型 下拉控件 -->
        <el-form-item>
            <el-select  v-model="form_aabbb.type" style="width: 100px" filterable clearable placeholder="类型">
                <el-option v-for="item in typeList" :key="item.value" :label="item.name" :value="item.value" />
            </el-select>
        </el-form-item>
        <!--状态 下拉控件 -->
        <el-form-item>
            <el-select  v-model="form_aabbb.status" style="width: 100px" filterable clearable placeholder="状态">
                <el-option v-for="item in statusList" :key="item.value" :label="item.name" :value="item.value" />
            </el-select>
        </el-form-item>
        <!-- 控件个数：[{"index":7,"raw":"name","name":"name","cname":"Name","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["c","u","LE","q","l","DN","#like"],"desc":{"raw":"名称","name":"名称"}} {"index":8,"raw":"value","name":"value","cname":"Value","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":true,"constraints":["c","u","q","LE","l","DI","color"],"desc":{"raw":"值","name":"值"}}] -->
         <el-form-item>
            <el-input clearable style="width: 180px" v-model="form_aabbb.single_text_value" maxlength="32"
                placeholder="关键字" >
                <template #prepend>
                    <el-select v-model="form_aabbb.single_text_name" placeholder="查询类型" style="width:84px;">
                        <el-option
                        v-for="item in multiQueryText"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      />
                      </el-select>
                  </template>
            </el-input>
        </el-form-item>

        <span class="ddl">
        </span>
        <el-form-item>
            <el-space wrap>
                <el-button type="primary" icon="Search" @click="onQuery(true)">查询数据</el-button>
                <el-button :type="$js.page.tagColor(0)"  icon="Plus"  @click="show_cmpnt_aabbf">添加分类</el-button>
            </el-space>
        </el-form-item>
        

        <!-- xtabs -->
        

    </el-form>
</div>
<div>
   <aabbf ref="cmpnt_aabbf" @onsaved="onQuery"></aabbf>
   <aabbc ref="cmpnt_aabbc" @onsaved="onQuery"></aabbc>
   <aabbd ref="cmpnt_aabbd" @onsaved="onQuery"></aabbd>
   <aabbe ref="cmpnt_aabbe" @onsaved="onQuery"></aabbe>
</div>
<div class="list">
    <el-table :data="dataList_aabbb" row-key="id" 
    
    v-loading="conf.loading" stripe  style="width: 100%;height:calc(100vh - 160px)"
         empty-text="无数据">le
        
        	<!--id text -->
        <el-table-column  show-overflow-tooltip    align="center" label="编号" >
            <template #default="scope">
                  <span>{{ scope.row.id||'-' }}</span>
              </template>
        </el-table-column>
        	<!--name text -->
        <el-table-column  show-overflow-tooltip    align="center" label="名称" >
            <template #default="scope">
                  <span>{{ scope.row.name||'-' }}</span>
              </template>
        </el-table-column>
        	<!--value text -->
        <el-table-column  show-overflow-tooltip    align="center" label="值" >
            <template #default="scope">
                  <span>{{ scope.row.value||'-' }}</span>
              </template>
        </el-table-column>
        	<!--sort_no text -->
        <el-table-column  show-overflow-tooltip    align="center" label="排序值" >
            <template #default="scope">
                  <span>{{ scope.row.sort_no||'-' }}</span>
              </template>
        </el-table-column>
        	<!--group_code text -->
        <el-table-column  show-overflow-tooltip    align="center" label="分组" >
            <template #default="scope">
                  <span>{{ scope.row.group_code||'-' }}</span>
              </template>
        </el-table-column>
        	<!--status switch -->
        <el-table-column     align="center" label="状态">
            <template #default="scope">
                <el-switch  @change="onstatusSwitchChange(scope.row,$event)"  v-model="scope.row.status_switch" />
            </template>
        </el-table-column>

<el-table-column fixed="right" align="center" label="操作" width="180">
    <template #default="scope">
        <div class="opts">
            <el-button   type="text" @click="show_cmpnt_aabbc(scope.row)" >添加值 </el-button>
            <el-button   type="text" @click="show_cmpnt_aabbd(scope.row)" >修改 </el-button>
            <el-button   type="text" @click="show_cmpnt_aabbe(scope.row)" >删除 </el-button>
        </div>
    </template>
</el-table-column>
    </el-table>
    <el-pagination :currentPage="form_aabbb.pi" :page-size="form_aabbb.ps"
        style="position: absolute; right: 30px;bottom:6px;" :page-sizes="[10,15,20,30, 50, 100]" :background="false" small
        layout="total,sizes,prev, pager, next, jumper" :total="total_aabbb" @size-change="handleSizeChange"
        @current-change="handleCurrentChange" />
</div>
  </div>
</template>
<script>
// 添加分类
import aabbf from "@/views/dds/dictionary/dictionary_info.add"
// 添加值
import aabbc from "@/views/dds/dictionary/dictionary_info.add"
// 修改
import aabbd from "@/views/dds/dictionary/dictionary_info.edit"
// 删除
import aabbe from "@/views/dds/dictionary/dictionary_info.cnfrm"



export default {
components: {
    aabbf,
    aabbc,
    aabbd,
    aabbe,
},
data() {
  return {
    shortcuts: this.$js.page.latestDays(),
    cmpnt_funcs:{},
    conf: {
      loading: false,
      progressColor: this.$theia.env.conf.progress || []
    },
    ganttIdx: -1,
        form_aabbb: {
            pi: 1,
            ps: 15,
            disabled:false,
            single_date_range_name:"",
            single_date_range_value:[],
            single_text_name:"",
            single_text_value:"",
            name:"",
            value:"",
            type:"",
            status:"",
            },
            typeList:[],
            statusList:[],
            dataList_aabbb:[],
            multiQueryDateRange:[],
            multiQueryText:[{label:"名称",value:"name"},{label:"值",value:"value"},],
            total_aabbb:0,
            note_dataList:[],
};
  },
mounted() {
  this.loadEnums_aabbb()
  this.form_aabbb.single_date_range_name = (this.multiQueryDateRange[0]||{}).value
  this.form_aabbb.single_text_name = (this.multiQueryText[0]||{}).value
  this.cmpnt_funcs["aabbf"] = this.show_cmpnt_aabbf
  this.cmpnt_funcs["aabbc"] = this.show_cmpnt_aabbc
  this.cmpnt_funcs["aabbd"] = this.show_cmpnt_aabbd
  this.cmpnt_funcs["aabbe"] = this.show_cmpnt_aabbe

  this.form_aabbb = Object.assign(this.form_aabbb,this.$route.params)
  this.queryData_aabbb ()
    },
methods: {
  ganttChange(id) {
      this.ganttIdx = id
    },

queryData_aabbb(mform = {},nform={}){
    //构建查询参数
    let queryForm = Object.assign({},this.form_aabbb)
    queryForm = Object.assign(queryForm,nform||{})
    
    //处理多个日期选择
    queryForm[this.form_aabbb.single_date_range_name] = this.form_aabbb.single_date_range_value
    queryForm[this.form_aabbb.single_text_name] = this.form_aabbb.single_text_value
   
    //处理日期范围选择

    queryForm[this.form_aabbb.single_date_range_name] = null
    queryForm.single_date_range_value = null
    queryForm.single_date_range_name = null

    queryForm.single_text_value = null
    queryForm.single_text_name = null
 
    //处理关联表dictionary_info dictionary_info dictionary_info
        queryForm.value = mform.type
   
    //发送查询请求
    let that = this
    that.conf.loading = true
    //构建统计查询
  //数据查询
  this.$theia.http.get("/dds/dictionary/info/query",queryForm).then(res=>{
      if((res.items||[]).length < (queryForm.ps||10)){
        that.form_aabbb.disabled = true
      }
      that.conf.loading = false
      that.dataList_aabbb = res.items||[]
      that.total_aabbb = res.count
      that.resetItemData_aabbb(that,that.dataList_aabbb)
    });
  },

  resetItemData_aabbb(that,lst){
    lst.forEach(item => {
      item.__raw = Object.assign({}, item)
    item.type_label = that.$theia.enum.getName("dictionary_info",item.type)
    item.status_label = that.$theia.enum.getName("status",item.status)
    item.id_progress = item.id
    item.name_progress = item.name
    item.value_progress = item.value
    item.type_progress = item.type
    item.sort_no_progress = item.sort_no
    item.group_code_progress = item.group_code
    item.status_switch = item.status == 0
    item.le_id = item.id
    item.le_name = item.name
    item.le_value = item.value
    item.le_type = item.type
    item.le_sort_no = item.sort_no
    item.le_group_code = item.group_code
    item.le_status = item.status
    if(item.children){
      that.resetItemData_aabbb(that,item.children)
    }
  });
  },
  onstatusSwitchChange(xfrom,v) {
      let form = {}
      form.status = v == true? 0 : 1;
      form.id = xfrom.id
      let that = this
      this.$theia.http.post("/dds/dictionary/info/switch",form).then(res=>{
        that.$notify.success({title: '成功',message: '修改状态成功',duration:5000})
      }).catch(res=>{
        v = !v
        let code = ((res||{}).response||{}).status||0
        let msg = `修改状态失败(${code})`
        that.$notify.error({title: '失败',message: msg,duration:5000})
      });
  },
    loadEnums_aabbb(){
        //类型
        this.typeList = this.$theia.enum.get("dictionary_info","","" ,false,"")
        //状态
        this.statusList = this.$theia.enum.get("status","","" ,false,"")
        //状态
        this.statusList = this.$theia.enum.get("status","","" ,false,"")
    },

  handleSizeChange(ps){
    this.form_aabbb.ps = ps
    this.onQuery(true)
  },
  handleCurrentChange(pi){
    this.form_aabbb.pi = pi
    this.onQuery()
  },
  onQuery(refresh){
    if(refresh){
      this.form_aabbb.pi = 1
    }
    this.queryData_aabbb ()
  },
show_cmpnt(cmd,row){
  if(this.cmpnt_funcs[cmd]){
    this.cmpnt_funcs[cmd](row)
  }
},
  //添加值
  show_cmpnt_aabbc(fm = {}){
    let query = {} 
    query.name = fm.name|| fm.le_name 
    query.value = fm.value|| fm.le_value 
    query.sort_no = fm.sort_no|| fm.le_sort_no 
    query.group_code = fm.group_code|| fm.le_group_code 
    query.status = fm.status|| fm.le_status 
    query.id = fm.id

      //2023.4.18添加---
    query.name = ""
    query.sort_no = ""
    query.type = fm.value
    query.value = ""

    query.$title="添加值"
    this.$refs.cmpnt_aabbc.show(query)
  },
  //添加分类
  show_cmpnt_aabbf(fm = {}){
    let query = {} 
    query.name = fm.name|| fm.le_name 
    query.value = fm.value|| fm.le_value 
    query.sort_no = fm.sort_no|| fm.le_sort_no 
    query.group_code = fm.group_code|| fm.le_group_code 
    query.status = fm.status|| fm.le_status 
    query.id = fm.id

      //2023.4.18添加---
    query.sort_no = "1"
    query.status = "0"
    query.type = "--"

    query.$title="添加分类"
    this.$refs.cmpnt_aabbf.show(query)
  },
  //修改
  show_cmpnt_aabbd(fm = {}){
    let query = {} 
    query.name = fm.name|| fm.le_name 
    query.value = fm.value|| fm.le_value 
    query.sort_no = fm.sort_no|| fm.le_sort_no 
    query.group_code = fm.group_code|| fm.le_group_code 
    query.status = fm.status|| fm.le_status 
    query.id = fm.id

      //2023.4.18添加---

    query.$title="修改"
    this.$refs.cmpnt_aabbd.show(query)
  },
  //删除
  show_cmpnt_aabbe(fm = {}){
    let query = {} 
    query.id = fm.id|| fm.le_id 
    query.id = fm.id

      //2023.4.18添加---

    query.$title="删除"
    this.$refs.cmpnt_aabbe.show_aabbe(query)
  },
},
};
</script>
<style>
.el-dialog{
  border-radius:5px !important
}
</style>
<style scoped>
.el-form-item {
  margin-right: 10px !important;
}

.opts .el-button--small {
  margin-left: 0px;
  padding-left: 0px;
  margin-right: 4px;
}

/deep/.el-table td.el-table__cell div {
  vertical-align: middle;
}
/deep/.el-button+.el-dropdown{
  margin-left:0px;
}
/deep/.el-button+.el-button{
  margin-left:0px;
}
.el-button{
  padding-left: 6px !important;
  padding-right: 6px !important;
}
.blist {
  margin-bottom: 8px;
  width: 100%;
}

.blist .el-radio-group {
  margin-right: 8px;
}

.ddl {
  margin-bottom: 8px;
  width: 100%;

}

.ddl .el-dropdown {
  margin-right: 8px;
}

.listbar {
  margin-bottom: 8px;
  text-align: center;
}
 .el-dropdown-link {
  cursor: pointer;
  color: var(--el-color-primary);
  display: flex;
  align-items: center;
  font-size: 0.65rem;
}
/deep/.el-button--small{
  padding: 5px 4px;
}

.prepend /deep/.el-input__wrapper{
  border-top-right-radius:0;
  border-bottom-right-radius:0;
}
.prepend+/deep/.el-date-editor{
  border-top-left-radius:0;
  border-bottom-left-radius:0;
  border-left:0;
}

</style>